using UnityEngine;
using UnityEngine.UI;

public class BrushPreview : MonoBehaviour
{
	[SerializeField]
	private Image m_BrushPreview;

	private void Awake()
	{
		BrushSizeController.OnValueChangedEvent += BrushSizeControllerOnOnValueChangedEvent;
		ColorButton.OnColorButtonClicked += ColorButtonOnOnColorButtonClicked;
	}

	private void OnDestroy()
	{
		BrushSizeController.OnValueChangedEvent -= BrushSizeControllerOnOnValueChangedEvent;
		ColorButton.OnColorButtonClicked -= ColorButtonOnOnColorButtonClicked;
	}

	private void Start()
	{
		InitDefaultBrush();
	}

	private void InitDefaultBrush()
	{
		m_BrushPreview.transform.localScale = Vector3.one * 0.5f;
		m_BrushPreview.color = Color.red;
	}

	private void ColorButtonOnOnColorButtonClicked(Color _Color)
	{
		m_BrushPreview.color = _Color;
	}

	private void BrushSizeControllerOnOnValueChangedEvent(float _Value)
	{
		float num = Mathf.Lerp(0.23f, 1f, _Value);
		m_BrushPreview.transform.localScale = Vector3.one * num;
	}
}
